﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 合成复用原则
{
    public interface IColor
    {
        public string ShowCar();
    }
    public class Green : IColor
    {
        public string ShowCar()
        {
            return "绿色";
        }
    }
    public class Red : IColor
    {
        public string ShowCar()
        {
            return "红色";
        }
    }
    //）——————————————————————————————————————————————————

    public abstract class Car
    {
        public abstract void Run(IColor color);
    }
    public class QyCar : Car
    {
        public override void Run(IColor color)
        {
            Console.WriteLine($"汽油式的{color.ShowCar()}颜色车在行驶");
        }
    }
    public class DdCar : Car
    {
        public override void Run(IColor color)
        {
            Console.WriteLine($"电动式的{color.ShowCar()}颜色车在行驶");
        }
    }
}
